﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace produccion.forms
{
    /// <summary>
    /// Lógica de interacción para FRMdetCanEntSal.xaml
    /// </summary>
    public partial class FRMdetCanEntSal : Window
    {
        public FRMdetCanEntSal()
        {
            InitializeComponent();
        }

        private void butSal_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void dataGrid1_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            var elemento = e.OriginalSource as UIElement;
            if (e.Key == Key.Enter && elemento != null)
            {
                e.Handled = true;
                elemento.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
            }
        }

        private void dataGrid1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (infEntSal.Instance.strTipo.Substring(0, 1) == "E")
            {
                FRMrImpEnt frm = new FRMrImpEnt();
                if (infEntSal.Instance.strTipo == "EN")
                    frm.rNor.IsChecked = true;
                if (infEntSal.Instance.strTipo == "ED")
                    frm.rDev.IsChecked = true;
                if (infEntSal.Instance.strTipo == "EM")
                    frm.rMuestra.IsChecked = true;
                if (infEntSal.Instance.strTipo == "EA")
                    frm.rAju.IsChecked = true;
                if (infEntSal.Instance.strTipo == "EO")
                    frm.rOtro.IsChecked = true;
                frm.texEnt.Text = infEntSal.Instance.detCan.Rows[infEntSal.Instance.SelDetCan]["NRODOC_TMP"].ToString();
                
                frm.rImpEnt.imprimirDirecto();
            }
            else
            {
                FRMrImpSal frm = new FRMrImpSal();
                if (infEntSal.Instance.strTipo == "SD")
                    frm.radioButton1.IsChecked = true;
                if (infEntSal.Instance.strTipo == "SP")
                    frm.radioButton2.IsChecked = true;
                if (infEntSal.Instance.strTipo == "SO" )
                    frm.radioButton3.IsChecked = true;

                frm.textBox1.Text = infEntSal.Instance.detCan.Rows[infEntSal.Instance.SelDetCan]["NRODOC_TMP"].ToString();

                frm.rImpSal.imprimirDirecto();
            }
            
        }

        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            var elemento = e.OriginalSource as UIElement;
            if (e.Key == Key.F3 && elemento != null)
            {
                if (MDOgeneral.logBusquedadAbierta == true) { MDOgeneral.logBusquedadAbierta = false; }
            }

            if (e.Key == Key.F4 && elemento != null)
            {
                if (MDOgeneral.logBusquedadAbierta1 == true) { MDOgeneral.logBusquedadAbierta1 = false; }
            }

            if (e.Key == Key.F5 && elemento != null)
            {
                if (MDOgeneral.logBusquedadAbierta2 == true) { MDOgeneral.logBusquedadAbierta2 = false; }
            }
        }
    }
}
